package com.ag.oa.core.controller;

import com.ag.oa.core.entity.dto.WebQRCodeLoginDTO;
import com.ag.oa.core.service.IWebQRCodeLoginService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping({"/webQR", "/test/webQR"})
public class WebQRCodeLoginController {

    private static final Logger logger = LoggerFactory.getLogger(WebQRCodeLoginController.class);

    @Autowired
    private IWebQRCodeLoginService webQRCodeLoginService;

    @GetMapping("/checkQRCode")
    public Boolean checkQRCode(String loginCode, Long scancodeTime) {

        Boolean flag = false;
        try {
            flag = webQRCodeLoginService.checkQRCode(loginCode, scancodeTime);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
        return flag;
    }

    @PostMapping("/updateSuccessAuthorization")
    public Boolean updateSuccessAuthorization(@RequestBody WebQRCodeLoginDTO webQRCodeLoginDTO) {

        Boolean flag = false;
        try {
            flag = webQRCodeLoginService.updateSuccessAuthorization(webQRCodeLoginDTO);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
        return flag;
    }

}
